<?php
	if (!session_start()) session_start();
	if (!isset($_SESSION['kiemtradangnhapthinguyet']) || $_SESSION['kiemtradangnhapthinguyet']!=1) {
		header('location: ../../../index.php');
		die();
	}
	$table = "users";
	if(isset($_POST['ok']))
	{
		$email=$_POST['email'];
			$res_mail=$qt->get_by_thutu($table,-1,-1,"and email='$email'");
			$kq=mysql_num_rows($res_mail);
			if($kq>=1)
			{ echo "<script>alert('Email này đã có ng đăng kí rồi vui lòng chọn email khác!!');history.go(-1);</script>";
				return;
			}
		$field = 'email,password,hoten,dienthoai,diachi,ngay,thutu';
		
		$now = getdate();
		$ngay = $now["year"]."-".$now["mon"]."-".$now["mday"]." ".$now["hours"].":".$now["minutes"].":".$now["seconds"];
		
		$values= format($_POST['email'],1);
		$values.= format(md5($_POST["password"]),1);
		$values.= format($_POST["hoten"],1);
		$values.= format($_POST["dienthoai"],1);
		$values.= format($_POST["diachi"],1);
		$values.= format($ngay,1);
		$values.= format($qt->get_thutu($table),0);
		$res=$qt->insertObject($table,$field,$values);
		
		if($res){
			echo "<script>alert('Thêm dữ liệu thành công !!!');history.go(-1);</script>";
		}
	}
	
?>
<script type="text/javascript">
function isTest() {
	if (document.getElementById("email").value=="") {
		alert("You have not entered enough information.");
		document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("password").value=="") {
		alert("You have not entered enough information.");
		return false;
	}
	
    return true;
}
</script>		
            	<div class="dangnhap_title">
                <a href="index.php" style="color:#F8991D;" title="Trang chủ">Trang chủ</a>
                <span style="font-size:9px;">>></span> 
                Sản phẩm
                <span style="font-size:9px;">>></span> 
                <a href="index.php?p=<?php echo $table; ?>_quanly" style="color:#F8991D;">Users</a> 
            	</div>
            	<form method="post" action="index.php?p=<?php echo $table; ?>_them" onSubmit="return isTest();">
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title" style="font-size:22px; color:#0E6BBB; width: 90%;">
                        Vietnamese's Information
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Email(*)
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="text" name="email" id="email" style="width:520px; padding:0px;" />
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Password(*)
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="password" name="password" id="password" style="width:520px; padding:0px;" />
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Họ tên
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="text" name="hoten" id="hoten" style="width:520px; padding:0px;" />
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Địa chỉ
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="text" name="diachi" id="diachi" style="width:520px; padding:0px;" />
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Điện thoại
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="text" name="dienthoai" id="dienthoai" style="width:520px; padding:0px;" />
                    </div>
                </div>
                
                <div class="dangnhap_col">
                    <div class="dangnhap_col_input">
                        <input type="submit" class="ok" border="0" name="ok" id="ok" value="" />
                        <a href="javascript:history.go(-1);"><img src="imgs/exit_button.png" border="0" /></a>
                    </div>
                </div>
               	</form>